home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DEMO.ZIP / DEMO01.PAS < prev    next >
Pascal/Delphi Source File  |  1993-09-24  |  2KB  |  95 lines

  1. Program Demo1;
  2.  
  3. { SPX library - Parallax demo  Copyright 1993 Scott D. Ramsay  }
  4.  
  5. Uses crt,spx_vga,spx_eff,spx_key,spx_img;
  6.  
  7. const
  8.   path = '';    { default work path }
  9.  
  10. type
  11.   PMyCycle = ^TmyCycle;
  12.   TMyCycle = object(TCycle)
  13.                procedure cycle_move; virtual;
  14.              end;
  15.  
  16. var
  17.   MyCycle : PMyCycle;
  18.   nsize   : integer;
  19.  
  20. procedure setup;
  21. begin
  22.   openmode(2);
  23.   setpageactive(2);         { set page 2 as the active page }
  24.   loadpcx(path+'fire.pcx'); { load pcx file on page 2 }
  25.   fsetcolors(rgb256);       { set the palette to the pcx palette }
  26.   nsize := 30;
  27.   MyCycle := new(PMyCycle,init(50,nsize));
  28. end;
  29.  
  30.  
  31. procedure animate;
  32. begin
  33.   repeat
  34.     if minus and (nsize>0)
  35.       then
  36.         begin
  37.           dec(nsize);
  38.           MyCycle^.changewave(50,nsize);
  39.         end
  40.       else
  41.     if plus and (nsize<100)
  42.       then
  43.         begin
  44.           inc(nsize);
  45.           MyCycle^.changewave(50,nsize);
  46.         end;
  47.     if space
  48.       then MyCycle^.docycle(2,1,1)
  49.       else MyCycle^.docycle(2,1,2);
  50.   until esc;
  51.   fadeout(40,rgb256);
  52. end;
  53.  
  54. (**) { TCycle Methods }
  55.  
  56. procedure TMyCycle.cycle_move;
  57. begin
  58.   if np[6,2] or np[9,2] or np[3,2]
  59.     then cyclex := (cyclex+1) mod 320
  60.     else
  61.       if np[4,2] or np[7,2] or np[1,2]
  62.         then cyclex := (cyclex+319) mod 320;
  63.   if np[8,2] or np[7,2] or np[9,2]
  64.     then cycley := (cycley+1) mod 200
  65.     else
  66.       if np[1,2] or np[2,2] or np[3,2]
  67.         then cycley := (cycley+199) mod 200;
  68. end;
  69.  
  70.  
  71. procedure showit;
  72. begin
  73.    clrscr;
  74.    writeln('SPX library - Parallax demo');
  75.    writeln('Copyright 1993 Scott D. Ramsay');
  76.    writeln;
  77.    writeln('Keys:');
  78.    writeln(' ESC          - quit demo');
  79.    writeln(' Arrow keys   - scroll background');
  80.    writeln(' +/-          - change amplitude');
  81.    writeln(' SPACE        - Still background');
  82.    writeln;
  83.    write('Press SPACE to continue.');
  84.    clearbuffer;
  85.    repeat until space;
  86. end;
  87.  
  88.  
  89. begin
  90.   showit;
  91.   setup;
  92.   animate;
  93.   dispose(MyCycle,done);
  94.   closemode;
  95. end.